/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIUsuarioNormal.java
 *
 * Created on 30/05/2011, 02:38:32 PM
 */
package gui;
import controlador.*;
import javax.swing.*;

/**
 *
 * @author Gamboa Family
 */
public class GUIUsuarioNormal extends javax.swing.JFrame {
    String codigo;
    /** Creates new form GUIUsuarioNormal */
    public GUIUsuarioNormal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel5 = new javax.swing.JPanel();
        jPanelFunciones = new javax.swing.JPanel();
        BConsultaGeneral = new javax.swing.JButton();
        BConsultaAvanzada = new javax.swing.JButton();
        BMiPerfil = new javax.swing.JButton();
        jPanelNotificaciones = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTANotificaciones = new javax.swing.JTextArea();
        jPanelCentral = new javax.swing.JPanel();
        jLabel57 = new javax.swing.JLabel();
        jBCerrarSesion2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));

        jPanelFunciones.setBackground(new java.awt.Color(242, 242, 242));
        jPanelFunciones.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(235, 30, 30)));

        BConsultaGeneral.setBackground(new java.awt.Color(255, 255, 255));
        BConsultaGeneral.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        BConsultaGeneral.setForeground(new java.awt.Color(235, 30, 30));
        BConsultaGeneral.setMnemonic('G');
        BConsultaGeneral.setText("Consulta General");
        BConsultaGeneral.setToolTipText("Pulse para buscar Materiales en la biblioteca.");
        BConsultaGeneral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BConsultaGeneralActionPerformed(evt);
            }
        });

        BConsultaAvanzada.setBackground(new java.awt.Color(255, 255, 255));
        BConsultaAvanzada.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        BConsultaAvanzada.setForeground(new java.awt.Color(235, 30, 30));
        BConsultaAvanzada.setMnemonic('A');
        BConsultaAvanzada.setText("Consulta Avanzada");
        BConsultaAvanzada.setToolTipText("Pulse para buscar Materiales de forma avanzada en la biblioteca.");
        BConsultaAvanzada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BConsultaAvanzadaActionPerformed(evt);
            }
        });

        BMiPerfil.setBackground(new java.awt.Color(255, 255, 255));
        BMiPerfil.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        BMiPerfil.setForeground(new java.awt.Color(235, 30, 30));
        BMiPerfil.setMnemonic('P');
        BMiPerfil.setText("Mi Perfil");
        BMiPerfil.setToolTipText("Pulse para ver y modifcar su información personal.");
        BMiPerfil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMiPerfilActionPerformed(evt);
            }
        });

        jPanelNotificaciones.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Notificaciones", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 14), new java.awt.Color(235, 30, 30))); // NOI18N

        jTANotificaciones.setColumns(20);
        jTANotificaciones.setFont(new java.awt.Font("Verdana", 0, 13));
        jTANotificaciones.setLineWrap(true);
        jTANotificaciones.setRows(5);
        jTANotificaciones.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTANotificaciones);

        javax.swing.GroupLayout jPanelNotificacionesLayout = new javax.swing.GroupLayout(jPanelNotificaciones);
        jPanelNotificaciones.setLayout(jPanelNotificacionesLayout);
        jPanelNotificacionesLayout.setHorizontalGroup(
            jPanelNotificacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
        );
        jPanelNotificacionesLayout.setVerticalGroup(
            jPanelNotificacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanelFuncionesLayout = new javax.swing.GroupLayout(jPanelFunciones);
        jPanelFunciones.setLayout(jPanelFuncionesLayout);
        jPanelFuncionesLayout.setHorizontalGroup(
            jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BConsultaGeneral, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addComponent(BConsultaAvanzada, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BMiPerfil, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                    .addGap(4, 4, 4)
                    .addComponent(jPanelNotificaciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(4, 4, 4)))
        );
        jPanelFuncionesLayout.setVerticalGroup(
            jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BConsultaGeneral)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BConsultaAvanzada)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BMiPerfil)
                .addContainerGap(578, Short.MAX_VALUE))
            .addGroup(jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                    .addGap(177, 177, 177)
                    .addComponent(jPanelNotificaciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(177, Short.MAX_VALUE)))
        );

        jPanelCentral.setBackground(new java.awt.Color(255, 255, 255));
        jPanelCentral.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(235, 30, 30)));

        jLabel57.setBackground(new java.awt.Color(255, 255, 255));
        jLabel57.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/imagen.JPG"))); // NOI18N

        jBCerrarSesion2.setBackground(new java.awt.Color(255, 255, 255));
        jBCerrarSesion2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/cerrarSesion.png"))); // NOI18N
        jBCerrarSesion2.setToolTipText("Pulse para cerrar sesión.");
        jBCerrarSesion2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCerrarSesion2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanelFunciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanelCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 821, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel57, javax.swing.GroupLayout.DEFAULT_SIZE, 930, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBCerrarSesion2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(12, 12, 12)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel57, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBCerrarSesion2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelFunciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 694, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BConsultaGeneralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BConsultaGeneralActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelConsultaGeneral panelCentral = new PanelConsultaGeneral();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(false, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel consulta general");
}//GEN-LAST:event_BConsultaGeneralActionPerformed

    private void BConsultaAvanzadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BConsultaAvanzadaActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelConsultaAvanzada panelCentral = new PanelConsultaAvanzada();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, false, true);
        this.validate();
        this.repaint();
        System.out.println("Panel consulta general");
}//GEN-LAST:event_BConsultaAvanzadaActionPerformed

    private void BMiPerfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMiPerfilActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelMiperfil panelCentral = new PanelMiperfil(codigo);
        panelCentral.llenarFormulario();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, true, false);
        this.validate();
        this.repaint();
        System.out.println("Panel consulta general");
}//GEN-LAST:event_BMiPerfilActionPerformed

    private void jBCerrarSesion2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCerrarSesion2ActionPerformed
        // TODO add your handling code here:
        int respuesta = JOptionPane.showConfirmDialog(this, "¿Esta seguro "
                + "que desea Cerrar la Sesión?");
        if(respuesta == JOptionPane.YES_OPTION)
            System.exit(0);
}//GEN-LAST:event_jBCerrarSesion2ActionPerformed

    public void activarBotones(Boolean cg, Boolean ca, Boolean mp){
        BConsultaGeneral.setEnabled(cg);
        BConsultaAvanzada.setEnabled(ca);
        BMiPerfil.setEnabled(mp);
    }
    
    public void setCodigo(String codigo){
        this.codigo = codigo;
    }
    
    public void llenarAreaNotificaiones(){
        ControladorUsuario control = new ControladorUsuario();
        jTANotificaciones.setText(control.cargarNotificaciones(codigo));
    }
   
    /**
     * @param args the command line arguments
     */
   /* public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GUIUsuarioNormal().setVisible(true);
            }
        });
    }*/
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BConsultaAvanzada;
    private javax.swing.JButton BConsultaGeneral;
    private javax.swing.JButton BMiPerfil;
    private javax.swing.JButton jBCerrarSesion2;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanelCentral;
    private javax.swing.JPanel jPanelFunciones;
    private javax.swing.JPanel jPanelNotificaciones;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTANotificaciones;
    // End of variables declaration//GEN-END:variables
}
